home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / beep.arc / BEEP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-03-29  |  768 b   |  45 lines

  1. /* BEEP.C - Make a sound  */
  2.  
  3. #include "STDIO.H"
  4. #include "DOS.H"
  5. #include "TIME.H"
  6.  
  7. main()
  8. {
  9.     long freq = 0;
  10.     long dur = 0;
  11.     long a;
  12.     int l,h;
  13.     long ival;
  14.     unsigned char clock[8];
  15.     int timeval1,timeval2;
  16.  
  17.     printf("Enter frequency in Hz:        ");
  18.     scanf("%d",&freq);
  19.     printf("Enter duration in 100ths Sec: ");
  20.     scanf("%d",&dur);
  21.  
  22.     outp(67,182);
  23.  
  24.     a = 1193182L/freq;
  25.     h = a/256;
  26.     l = a-(h*256);
  27.     outp(66,l);
  28.     outp(66,h);
  29.  
  30.     
  31.     getclk(clock);
  32.     timeval1 = 100*clock[6]+clock[7];
  33.     outp(97,(inp(97) | 3));
  34.  
  35.     ival = 0L;
  36.     while (dur > ival)
  37.     {
  38.         getclk(clock);
  39.         timeval2 = 100*clock[6]+clock[7];
  40.         ival = timeval2 - timeval1;
  41.         if (ival < 0L) ival = ival + 6000;
  42.     }    
  43.     outp(97,(inp(97) & 252));
  44. }
  45.